package com.mudalov.rec.dao.model.user;

import com.mudalov.rec.dao.interfaces.IClonable;
import java.io.Serializable;
import java.util.Date;

public class Message implements Serializable, IClonable {

	private static final long serialVersionUID = 1265538648738290586L;

	private Long id;
	
	private String from;
	
	private String to;
	
	private String text;
	
	private Date date;

	public Message() {}

	public Message(Date date, String from, String text, String to) {
		super();
		this.date = date;
		this.from = from;
		this.text = text;
		this.to = to;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public String getTo() {
		return to;
	}

	public void setTo(String to) {
		this.to = to;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((date == null) ? 0 : date.hashCode());
		result = prime * result + ((from == null) ? 0 : from.hashCode());
		result = prime * result + (int) (id ^ (id >>> 32));
		result = prime * result + ((text == null) ? 0 : text.hashCode());
		result = prime * result + ((to == null) ? 0 : to.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Message))
			return false;
		Message other = (Message) obj;
		if (date == null) {
			if (other.date != null)
				return false;
		} else if (!date.equals(other.date))
			return false;
		if (from == null) {
			if (other.from != null)
				return false;
		} else if (!from.equals(other.from))
			return false;
		if (id != other.id)
			return false;
		if (text == null) {
			if (other.text != null)
				return false;
		} else if (!text.equals(other.text))
			return false;
		if (to == null) {
			if (other.to != null)
				return false;
		} else if (!to.equals(other.to))
			return false;
		return true;
	}

    public Message getClone() {
        Message clone = new Message();
        clone.setId(this.getId());
        clone.setFrom(this.getFrom());
        clone.setTo(this.getTo());
        clone.setDate(this.getDate());
        clone.setText(clone.getText());
        return clone;
    }
	
}
